export default {
	//首页时间转换
	dateTime(ddd){
		let old = new Date(ddd);
		let now = new Date();
		//获取old具体时间
		let d = old.getTime();
		let h = old.getHours();
		let m = old.getMinutes();
		let Y = old.getFullYear();
		let M = old.getMonth()+1;
		let D = old.getDate();
		//获取now具体时间
		let nd = now.getTime();
		let nh = now.getHours();
		let nm = now.getMinutes();
		let nY = now.getFullYear();
		let nM = now.getMonth()+1;
		let nD = now.getDate();
		//当天时间
		if(D == nD && Y == nY && M == nM){
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return  h + ':'+m;
		}
		
		//昨天时间
		if(D+1 == nD && Y == nY && M == nM){
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return "昨天 " + h + ':'+m;
		}
		else{
			return Y+"/"+M+"/"+D;
		}
		//大于两天的
		
	},
	
	//聊天时间
	dateTime2(ddd){
		let old = new Date(ddd);
		let now = new Date();
		//获取old具体时间
		let d = old.getTime();
		let h = old.getHours();
		let m = old.getMinutes();
		let Y = old.getFullYear();
		let M = old.getMonth()+1;
		let D = old.getDate();
		//获取now具体时间
		let nd = now.getTime();
		let nh = now.getHours();
		let nm = now.getMinutes();
		let nY = now.getFullYear();
		let nM = now.getMonth()+1;
		let nD = now.getDate();
		//当天时间
		if(D == nD && Y == nY && M == nM){
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return  h + ':'+m;
		}
		
		//昨天时间
		if(D+1 == nD && Y == nY && M == nM){
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return "昨天 " + h + ':'+m;
		}
		else if(Y == nY){
			//今年
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return M+"月"+D+"日 "+h + ':'+m
		}
		else{
			//大于今年
			if(h<10){
				h = "0" + h;
			}
			if(m<10){
				m = "0" + m;
			}
			return Y+"年 "+ M+"月"+D+"日 "+h + ':'+m
		}
		
		
	},
	
	//间隔时间差
	spaceTime(old,now){
		old = new Date(old);
		now = new Date(now);
		var tOld = old.getTime();
		var tNow = now.getTime();
		if(tOld>(tNow+1000*60*5)){
			return now;
		}else{
			return ''
		}
	}
	
}